package com.cqut.forum.entity;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * @author yangxun
 * GroupRelation entity
 */
@Entity
@Table(name = "group_relation", catalog = "forum")
public class GroupRelation implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer groupRelationId;
	private User user;
	private UserGroup userGroup;
	private Date relationTime;
	private String groupRole;
	private String groupRemarkName;
	private Boolean isOnline;

	// Constructors

	/** default constructor */
	public GroupRelation() {
	}

	/** full constructor */
	public GroupRelation(User user, UserGroup userGroup, Date relationTime,
			String groupRole, String groupRemarkName, Boolean isOnline) {
		this.user = user;
		this.userGroup = userGroup;
		this.relationTime = relationTime;
		this.groupRole = groupRole;
		this.groupRemarkName = groupRemarkName;
		this.isOnline = isOnline;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "group_relation_id", unique = true, nullable = false)
	public Integer getGroupRelationId() {
		return this.groupRelationId;
	}

	public void setGroupRelationId(Integer groupRelationId) {
		this.groupRelationId = groupRelationId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "group_id")
	public UserGroup getUserGroup() {
		return this.userGroup;
	}

	public void setUserGroup(UserGroup userGroup) {
		this.userGroup = userGroup;
	}

	@Column(name = "relation_time", length = 10)
	public Date getRelationTime() {
		return this.relationTime;
	}

	public void setRelationTime(Date relationTime) {
		this.relationTime = relationTime;
	}

	@Column(name = "group_role", length = 6)
	public String getGroupRole() {
		return this.groupRole;
	}

	public void setGroupRole(String groupRole) {
		this.groupRole = groupRole;
	}

	@Column(name = "group_remark_name", length = 20)
	public String getGroupRemarkName() {
		return this.groupRemarkName;
	}

	public void setGroupRemarkName(String groupRemarkName) {
		this.groupRemarkName = groupRemarkName;
	}

	@Column(name = "is_online")
	public Boolean getIsOnline() {
		return this.isOnline;
	}

	public void setIsOnline(Boolean isOnline) {
		this.isOnline = isOnline;
	}

}